<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我要发布</title>
    <link rel="stylesheet" href="layui/css/layui.css"/>
    <script type="text/javascript" rel="stylesheet" src="jquery-1.9.1.js"></script>
    <script type="text/javascript" src="layui/layui.all.js"></script>
    <script>
        var layer = layui.layer //弹层
    </script>
</head>
<body>
<div>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" style=" margin-top: 20px;width: 1100px !important;" name="title" required
                       lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input text">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文本域</label>
            <div class="layui-input-block">
                <textarea name="desc" placeholder="请输入内容" class="layui-textarea area"
                          style="height: 460px; width: 1100px !important;"></textarea>
            </div>
        </div>
        <input type="button" value="&nbsp; 我要发布	&nbsp;" style="display: inline;float: left; margin-left: 400px"
               class="layui-btn layui-btn-lg layui-btn-normal tijiao"/>
        <input type="button" value="加入草稿箱" style="display: inline;float: left; margin-left: 200px"
               class="layui-btn layui-btn-lg layui-btn-normal caogao"/>
    </form>
</div>

<script type="text/javascript">
    $(".tijiao").click(function () {
        if ($(".text").val() != "" && $(".area").val() != ""){
            $.ajax({
                url: "/addartical",
                data:{title:$(".text").val(),artical:$(".area").val()},
                type:"POST"
            }).done(function (data) {
                layer.msg("保存成功");
            })
        }else{
            layer.msg("内容不能为空");
        }

    })
    $(".caogao").click(function () {
        if ($(".text").val() != "" && $(".area").val() != ""){
            $.ajax({
                url: "/adddraft",
                data:{title:$(".text").val(),artical:$(".area").val()},
                type:"POST"
            }).done(function (data) {
                layer.msg("保存成功");
            })
        }else{
            layer.msg("内容不能为空");
        }

    })
</script>
</body>
</html>